package com.mnb.base.service.impl;

import com.mnb.common.utils.R;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.mnb.base.entity.StRiverR;
import java.util.List;

import com.mnb.base.mapper.StRiverRMapper;
import com.mnb.base.service.StRiverRService;
import org.springframework.transaction.annotation.Transactional;

@Service
public class StRiverRServiceImpl implements StRiverRService{

    @Resource
    private StRiverRMapper stRiverRMapper;

    @Override
    public R getList(StRiverR stRiverR) {
        List<StRiverR> list = stRiverRMapper.getList(stRiverR);
        return R.ok(list);
    }

    @Override
    public R insert(StRiverR stRiverR) {
        StRiverR count = stRiverRMapper.selectByPrimaryKey(stRiverR.getStcd(), stRiverR.getTm());
        if (count != null) {
            return R.fail("数据已存在");
        }
        stRiverRMapper.insert(stRiverR);
        return R.ok();
    }

    @Override
    public R update(StRiverR stRiverR) {
        stRiverRMapper.updateByPrimaryKey(stRiverR);
        return R.ok();
    }

    @Override
    @Transactional
    public R delete(List<StRiverR> list) {
        for (StRiverR stRiverR : list) {
            stRiverRMapper.deleteByPrimaryKey(stRiverR.getStcd(), stRiverR.getTm());
        }
        return R.ok();
    }

    @Override
    public R getLineData(StRiverR stRiverR) {
        List<StRiverR> list = stRiverRMapper.getLineData(stRiverR);
        return R.ok(list);
    }

    @Override
    public R getWtypeList(StRiverR stRiverR) {
        List<StRiverR> list = stRiverRMapper.getWtypeList(stRiverR);
        return R.ok(list);
    }
}
